package com.example.common.constant;

/**
 * 通用业务常量
 * @author cui haida
 * @version JDK 8
 * 2025/8/4
 */
public class ServiceConstants {
    // white list -> no need token
    public static final String[] WHITE_LIST = new String[]{
            "/api/sysUser/login",
            "/api/sysUser/imageCode",
            "/favicon.ico",
            "/doc.html",
            "/swagger-resources",
            "/v2/api-docs",
            "/webjars/**"
    };

    // 服务名称常量 - open feign with ribbon will use this name
    public static final String AUTH_SERVICE = "micro-auth";
    public static final String USER_SERVICE = "micro-user";
    public static final String ORDER_SERVICE = "micro-order";
    public static final String GATEWAY_SERVICE = "micro-gateway";
    public static final String PRODUCT_SERVICE = "micro-product";

    // 请求头常量 - jwt / token will be stored in this header
    public static final String AUTHORIZATION_HEADER = "Authorization";
    public static final String BEARER_PREFIX = "Bearer ";
    public static final String USER_ID_HEADER = "X-User-Id";
    public static final String TRACE_ID_HEADER = "X-Trace-Id";

    // 时间格式 - do formatting date
    public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
    public static final String DATE_FORMAT = "yyyy-MM-dd";

    // 缓存前缀 - cache key will start with this prefix
    public static final String CACHE_AUTH_PREFIX = "auth:";
    public static final String CACHE_USER_PREFIX = "user:";
    public static final String CACHE_ORDER_PREFIX = "order:";

    // 权限相关 - user role
    public static final String ROLE_ADMIN = "ROLE_ADMIN";
    public static final String ROLE_USER = "ROLE_USER";

    // JWT Claims
    public static final String JWT_CLAIM_USER_ID = "userId";
    public static final String JWT_CLAIM_ROLES = "roles";
    public static final String JWT_CLAIM_ISSUER = "microservice-ecommerce";

    // 分页默认值 - page default
    public static final int DEFAULT_PAGE_SIZE = 10;
    public static final int DEFAULT_PAGE_NUM = 1;

    /**
     * map初始化大小
     */
    public static final int MAP_INIT_CAP = 16;

    /**
     * 空字符串
     */
    public static final String EMPTY = "";

    /**
     * mybatis最大分页
     */
    public static final long MAX_PAGE_COUNT = 800L;

    /**
     * 状态码
     */
    public static final int RESPONSE_SUCCESS = 200;//响应成功200
    public static final int RESPONSE_FAIL = -1;//响应失败-1
    public static final int ACCESS_DENIED_EXCEPTION = 403;//权限不足403
    public static final int RUNTIME_EXCEPTION = 500;//系统异常500
    public static final int IMAGE_CODE_EXCEPTION = 1001;//校验验证码失败1001
    public static final int AUTH_TOKEN_EXCEPTION = 1002;//校验token失败1002
    public static final int AUTH_TOKEN_EXPIRED_EXCEPTION = 1003;//请求token过期1003
    public static final int CUSTOM_AUTHENTICATION_EXCEPTION = 1004;//自定义认证异常1004
}